#ifndef IN_THREAD_H_
#define IN_THREAD_H_

#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/thread.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

#include "message.h"
#include "BufferQueue.h"

class InThread
    {
public:
    InThread(boost::asio::io_service& io);
    ~InThread();

    //thread function of this thread
    void operator()();

    static void inQueueHasDataWrapper(void * pObj);
    void inQueueHasData();
    void processQueue(Message * pMsg);
    void processMsg(Message * pMsg);
    void processInQueueData();

    BufferQueue<Message *> & getInQueue()
        {
        return inQueue;
        }

private:
    BufferQueue<Message *> inQueue;
    boost::condition_variable cond;
    boost::mutex mut;
    bool bInQueueDataReady; //inQueue has some data.
    };

#endif /* IN_THREAD_H_ */
